package javazuoye.three;

/**
 * @author: 唐小尊
 * @email: 1171702529@qq.com
 * @cate: 2021/06/27 09:49
 */
public class _6_2_9 {
    public static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }
    public static void main(String[] args) {
        TreeNode root = new TreeNode(1);
        root.left = new TreeNode(2);
        root.right = new TreeNode(3);
        root.left.left = new TreeNode(4);
        root.left.right = new TreeNode(5);
        root.right.left = new TreeNode(6);
        root.right.right = new TreeNode(7);
        xianxu(root,6);
    }
    
    public static void xianxu(TreeNode root,int val){
        System.out.println(root.val);
        if (root.val == val){
            return;
        }
        if (root.left!=null){
            xianxu(root.left,val);
        }
        if (root.right!=null){
            xianxu(root.right,val);
        }
    }
}
